package projcet.test.student.student;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbOpenHelper extends SQLiteOpenHelper{
    private static final String DB_NAME = "Student.db"; //数据库名称
    private static final int version = 1; //数据库版本


    public static final String CREATE_DB = "create table Student(" +
            "id integer primary key autoincrement," +
            "name varchar(20), " +
            "className text, "+
            "studentNo varchar(20)," +
            "subject varchar(20) ," +
            "score int )";

    public static final String TEACHER = "create table Teacher(" +
            "id integer primary key autoincrement," +
            "teacher varchar(20),subject varchar(20) )";





    public DbOpenHelper(Context context) {
        super(context,DB_NAME,null,version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_DB);
        db.execSQL(TEACHER);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists Student");
        db.execSQL("drop table if exists Teacher");

        onCreate(db);
    }
}
